package demo.practice.bit;

public class P268 {

    /*public int missingNumber(int[] nums) {

        int res= 0;
        for(int i=0;i<nums.length+1;i++){
            res^=i;
        }

        for (int num : nums) {
            res ^= num;
        }

        return res;
    }*/


    public int missingNumber(int[] nums) {
        int missing = nums.length;
        for (int i = 0; i < nums.length; i++) {
            missing ^= i ^ nums[i];
        }
        return missing;
    }
}
